<%@ Register TagPrefix="uc1" TagName="ShowHelp" Src="~/Controls/ShowHelp.ascx" %>

<%@ Page Language="c#" CodeBehind="EditElement.aspx.cs" AutoEventWireup="True" Inherits="FormsGenerator.EditElement"
    ValidateRequest="false" CodePage="65001" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
<head>
    <title>EditElement</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link href="Styles/Default.css" type="text/css" rel="stylesheet" />

    <script language="javascript" type="text/javascript">
		function updateForm(parGUID, parCloseWindow)
		{			
			window.opener.location = "EditForm.aspx?ID=" + parGUID;
			if (parCloseWindow)
			{
				window.close();
			}
		}
		
		var arrTabs = new Array();
				
		function showHideField(validationCheck, theField)
		{
			if (validationCheck != null && validationCheck != "undefined")
			{
				if (validationCheck.checked)
				{
					theField.style.display = "block";
				}
				else
				{
					theField.style.display = "none";			
				}
			}
		}		
		
		function showTab(parTabSelected)
		{
			var tabCounter = 1;
			for (var divId in arrTabs)
			{
				var objTabSelector = eval('tab' + tabCounter);
				arrTabs[divId].style.display = 'none';
				objTabSelector.className = 'tab';
				tabCounter++;
			}
			var objContainerToShow = eval("container_" + parTabSelected.id);
			if (objContainerToShow != null && objContainerToShow != "undefined")
			{
				objContainerToShow.style.display = 'block';
			}
			//var selector = eval('selector_' + par_object.id);
			parTabSelected.className = 'tabActive';
			document.EditElement.HiddenSelectedTab.value = parTabSelected.id;		
			
		}
		
		function initializePage()
		{			
			var objSelectedTab = null;
            if (document.EditElement.HiddenSelectedTab.value == "")
			{
                objSelectedTab = document.getElementById("tab1");
			}
			else
			{				
                objSelectedTab = document.getElementById(document.EditElement.HiddenSelectedTab.value);                
                //var objSelectedTab = eval(document.EditElement.HiddenSelectedTab.value);
				if (objSelectedTab == null || objSelectedTab == "undefined")
				{
                    objSelectedTab = document.getElementById("tab1");
                }										
			}
            
            if (objSelectedTab != null && objSelectedTab != "undefined")
            {
                showTab(objSelectedTab);
            }
		}
    </script>

</head>
<body>
    <form id="EditElement" method="post" runat="server">
    <asp:Label ID="LabelErrorMessage" runat="server" EnableViewState="False" CssClass="ErrorMessage"
        Visible="False"></asp:Label><asp:Label ID="LabelDebug" runat="server" EnableViewState="False"
            Visible="False"></asp:Label><asp:ValidationSummary ID="ValidationSummary1" runat="server"
                HeaderText="Please fill in mandatory fields"></asp:ValidationSummary>
    <asp:Panel ID="PanelEditElementHead" runat="server" CssClass="Panel" Width="100%">
        <table id="Table1" cellspacing="1" cellpadding="1" width="100%" border="0">
            <tr>
                <td>
                    <asp:Label ID="LabelAction" runat="server" EnableViewState="False"></asp:Label>
                </td>
                <td>
                    Type:
                    <asp:DropDownList ID="DropDownListElementTypes" runat="server" AutoPostBack="True"
                        OnSelectedIndexChanged="DropDownListElementTypes_SelectedIndexChanged">
                    </asp:DropDownList>
                </td>
                <td align="right">
                    <asp:Button ID="ButtonSave" runat="server" EnableViewState="False" Text="Save" Enabled="False"
                        OnClick="ButtonSave_Click"></asp:Button>
                </td>
            </tr>
        </table>
        <asp:Panel ID="PanelElementDescription" runat="server" Visible="False" CssClass="Instructions"
            EnableViewState="False" Width="100%">
            <asp:Label ID="LabelElementDescription" runat="server" EnableViewState="False"></asp:Label>
        </asp:Panel>
    </asp:Panel>
    <br />
    <table id="TableTabs" cellspacing="0" cellpadding="0" width="100%" border="0" runat="server">
        <tr>
        </tr>
    </table>
    <asp:Panel ID="PanelAttributes" runat="server" Width="100%">
    </asp:Panel>
    <br />
    <asp:Panel ID="PanelInstructions" runat="server" Visible="False" Width="100%" CssClass="Instructions"
        EnableViewState="False">
        <ul>
            <li>Use mouse over labels to se the description for the different fields.</li>
            <li>Click the tabs to switch between the tabs.</li>
            <li>Mandatory fields are <strong>bold</strong>&nbsp;</li></ul>
    </asp:Panel>
    <asp:Label ID="LabelExecuteJavascript" runat="server" Visible="False" EnableViewState="False"></asp:Label><input
        id="HiddenSelectedTab" type="hidden" name="HiddenSelectedTab" runat="server" />&nbsp;
    <br />
    <uc1:ShowHelp ID="ShowHelp" runat="server"></uc1:ShowHelp>
    <br />
    <!--
		<table width="100%" cellspacing="0" cellpadding="0" border="0">
			<tr>
				<td class="tabActive" id="selector_tab11"><a href="javascript:showTab(selector_tab11, tab11);">Reservasjoner</a></td>
				<td class="tab" id="selector_tab21"><a href="javascript:showTab(selector_tab11, tab21);">Tildelinger</a></td>
				<td class="tab" id="selector_tab31"><a href="javascript:showTab(selector_tab11, tab31);">Parkeringsplasser</a></td>
				<td class="tab" id="selector_tab41"><a href="javascript:showTab(selector_tab11, tab41);">Historikk</a></td>
				<td class="tabSpacer">&nbsp;</td>
			</tr>
		</table>
		
		<div id="tab11" style="DISPLAY:none" class="tabContainer">
			<b>Reservasjoner for i morgen:</b>
		</div>
		<div id="tab21" style="DISPLAY:none" class="tabContainer">
			<b>Tab 2:</b>
		</div>
		<div id="tab31" style="DISPLAY:none" class="tabContainer">
			<b>Tab 3:</b>
		</div>
		<div id="tab41" style="DISPLAY:none" class="tabContainer">
			<b>Tab 4:</b>
		</div>
		-->

    <script language="javascript" type="text/javascript">
		var divElements = document.getElementsByTagName("div");
		//alert ("count: " + divElements.length);
		var stringElements;
		if (divElements != null)
		{
			for (var i = 0; i < divElements.length; i++)
			{
				var divId = divElements[i].id;
				if (divElements[i].className == "tabContainer")
				{					
					arrTabs[divId] = divElements[i];
				}		
			}
		}
		
		var stringTabs = "";
		for (var divId in arrTabs)
		{
			stringTabs += divId + ": " + arrTabs[divId];
		}
		
		initializePage();
		
    </script>

    </form>
</body>
</html>
